import Vue from 'vue'
import App from './App'
import store from './store'
import MinCache from './common/util/MinCache.js'
import tip from './common/util/tip.js'
import configService from './common/service/config.service.js'

import router from './common/router'
import { RouterMount } from './plugin/uni-simple-router/index.js'

// 引入mescroll插件
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)

// 注册缓存器
Vue.use(MinCache, { timeout: 6 })

// 挂载全局属性
Vue.prototype.$store = store
Vue.prototype.$tip = tip
Vue.prototype.$config = configService

// request请求
import { http } from '@/common/service/service.js'
Vue.prototype.$http = http

// 注册页面组件
import home from './pages/home/home.vue'
Vue.component('home', home)

import people from './pages/user/people.vue'
Vue.component('people', people)

import mySelect from './components/my-componets/my-select.vue'
Vue.component('mySelect', mySelect)

import myImageUpload from './components/my-componets/my-image-upload.vue'
Vue.component('myImageUpload', myImageUpload)

import myPage from './components/my-componets/my-page.vue'
Vue.component('myPage', myPage)

import basics from './pages/basics/home.vue'
Vue.component('basics', basics)

import components from './pages/component/home.vue'
Vue.component('components', components)

import plugin from './pages/plugin/home.vue'
Vue.component('plugin', plugin)

import cuCustom from './plugin/colorui/components/cu-custom.vue'
Vue.component('cu-custom', cuCustom)

Vue.config.productionTip = false
App.mpType = 'app'

// 全局mixins，用于实现setData等功能，请勿删除
import zpMixins from '@/uni_modules/zp-mixins/index.js'
Vue.use(zpMixins)

// 条件编译区分不同环境
// #ifdef VUE2 && H5
const app = new Vue({
    router,
    store,
    ...App
})
RouterMount(app, '#app') // H5 使用 RouterMount
// #endif

// #ifdef VUE2 && !H5
const app = new Vue({
    store,
    ...App
})
app.$mount() // 小程序和 App 端使用 app.$mount
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
    const app = createSSRApp(App)
    app.mixin(zpMixins)
    return {
        app
    }
}
// #endif
